Skip to content

revert(toolbox-core): Reverts "fix(toolbox-core): Prevent ToolboxClient from closing externally managed client sessions" #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

anubhav756
Copy link
Contributor

@anubhav756 anubhav756 commented Jun 4, 2025

This PR reverts the __del__ method that was added to ToolboxClient and ToolboxSyncClient (#260) as a safety-net (context) to close the underlying client session.

Reasoning for Reversion

The __del__ method was intended to prevent resource leaks by closing sessions that users forgot to close manually. However, it introduced a critical bug in production scenarios.

The issue arises when the ToolboxClient or ToolboxSyncClient instance, which manages the session, goes out of scope, while the tools it loaded remain in use. This triggers the __del__ method on the client, prematurely closing the session and causing any ongoing operations by the tools to fail.

This problem affects:

  • ToolboxClient: When it manages its own session.
  • ToolboxSyncClient: In all use cases, as it always manages its own session in a background thread.

Given that the documented methods for session management (async with and client.close()) are sufficient, this safety-net was causing more harm than good. Removing it restores the expected behavior and prevents these unintended session closures.

@anubhav756 anubhav756 force-pushed the revert-260-anubhav-manage-session branch from 356c555 to 3ccdfad Compare June 4, 2025 05:40
@anubhav756 anubhav756 changed the title Revert "fix(toolbox-core): Prevent ToolboxClient from closing externally managed client sessions" revert: Reverts "fix(toolbox-core): Prevent ToolboxClient from closing externally managed client sessions" Jun 4, 2025
@anubhav756 anubhav756 self-assigned this Jun 4, 2025
@anubhav756 anubhav756 marked this pull request as ready for review June 4, 2025 05:47
@anubhav756 anubhav756 requested a review from a team as a code owner June 4, 2025 05:47
@anubhav756 anubhav756 force-pushed the revert-260-anubhav-manage-session branch from 3ccdfad to 46e1334 Compare June 4, 2025 05:49
@twishabansal
Copy link
Contributor

Why are we reverting these changes?

@anubhav756 anubhav756 changed the title revert: Reverts "fix(toolbox-core): Prevent ToolboxClient from closing externally managed client sessions" revert(toolbox-core): Reverts "fix(toolbox-core): Prevent ToolboxClient from closing externally managed client sessions" Jun 4, 2025
@anubhav756
Copy link
Contributor Author

Why are we reverting these changes?

Added the details in the description. Let me know in case you need more context. 🙂

@anubhav756 anubhav756 merged commit 30053ea into main Jun 4, 2025
19 checks passed
@anubhav756 anubhav756 deleted the revert-260-anubhav-manage-session branch June 4, 2025 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants